package com.mrx.xfriendship.converter;

import com.mrx.xfriendship.model.SecurityUser;
import com.mrx.xfriendship.model.dto.SecurityUserDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingConstants;
import org.mapstruct.ReportingPolicy;

import java.util.Collections;

/**
 * @author Mr.X
 * @since 2023-01-14 21:26
 */
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING,
        imports = Collections.class,
        unmappedTargetPolicy = ReportingPolicy.IGNORE
)
public interface SecurityUserConverter {

    @Mapping(target = "role", expression = "java( Collections.singletonList(dto.getRole()) )")
    SecurityUser toSecurityUser(SecurityUserDTO dto);

}
